import http from '@/utils/http.js'

// 获取预订单（购物车）接口
export function createPreOrderOfCartAPI() {
    return http.get(`/shoppingOrder/createPreOrderOfCart`);
}

/**
 * 预订单信息获取（商品详情页）
 * @param {object} params GoodsSkuOrderRequest
 * @param {number} params.skuId
 * @param {number} params.quantity
 * @returns
 */
export function createPreOrderOfGoodsSkuAPI(params) {
    return http.post(`/shoppingOrder/createPreOrderOfGoodsSku`, params);
}

/**
 * 创建订单
 * @param {object} params OrderCreateRequest
 * @param {number} params.deliveryTimeType
 * @param {number} params.payType
 * @param {array} params.buyGoodsSkuList
 * @param {number} params.addressId
 * @returns
 */
export function createOrderAPI(params) {
    return http.post(`/shoppingOrder/createOrder`, params);
}

/**
 * 获取当前已支付订单信息
 * @param {string} orderId
 * @returns
 */
export function payDoneOrderAPI(orderId) {
    return http.get(`/shoppingOrder/payDoneOrder/${orderId}`);
}

/**
 * 获取各类订单状态
 * @param {object} params OrderQueryRequest
 * @param {number} params.pageSize
 * @param {number} params.current
 * @param {number} params.orderStatus
 * @returns
 */
export function getOrderByStatusAPI(params) {
    return http.post(`shoppingOrder/getOrderByStatus`, params);
}

/**
 * 订单发货
 * @param {string} orderId
 * @returns
 */
export function toSendGoodsAPI(orderId) {
    return http.post(`/shoppingOrder/toSend?orderId=${orderId}`);
}